/* Copyright (c) 2024 Qualcomm Technologies International, Ltd. */
/* %%version */

#ifndef GATT_OTS_CLIENT_COMMON_UTIL_H_
#define GATT_OTS_CLIENT_COMMON_UTIL_H_

#include "gatt_ots_client_private.h"

#define OTSC_ADD_SERVICE_HANDLE(_List)                                        \
    (ServiceHandleListElm_t *)CsrCmnListElementAddLast(&(_List),              \
                                              sizeof(ServiceHandleListElm_t))

#define OTSC_REMOVE_SERVICE_HANDLE(_List,_Element)                            \
    (CsrCmnListElementRemove(&(_List),                                        \
                             (CsrCmnListElm_t *)(_Element)))

typedef struct
{
    CsrUint32 cid;
    CsrUint16 startHandle;
    CsrUint16 endHandle;
#ifndef SYNERGY_CHP_ENABLE
    AppTask         clientTask;
#endif
} GattClientRegistrationParams;

GattOtscResultCode OtscGetResultCodeFromGattStatus(status_t status);

ServiceHandle GattOtscGetServiceHandle(GOTSC **gattOtsClient,CsrCmnList_t *list);

GattOtsClient *GattOtscGetMainInstance(void);

void GattOtscInitServiceHandleList(CsrCmnListElm_t *elem);

GattOtscDeviceData *GattOtscGetDeviceDataReq(ServiceHandle clntHndl);

CsrBool OtscFindSrvcHndlByConnId(CsrCmnList_t *list, CsrBtConnId btConnId, GOTSC **gattOtsClient);

ServiceHandle GattOtscGetCharacHandleForCharacId(GOTSC *const gattOtsClient,
                                                 GattOtscCharacteristicsId characId);

GattOtscCharacteristicsId GattOtscGetCharacIdForCharacHandle(GOTSC *const gattOtsClient,
                                                             ServiceHandle handle);

void OtscStartOacpTimer(GOTSC *const gattOtsClient);

void OtscStartOlcpTimer(GOTSC *const gattOtsClient);

#endif /* GATT_OTS_CLIENT_COMMON_UTIL_H_ */

